{% extends 'base_right.html' %}

{% block bodycontent %}
    <div class="content">
        <form id="form" class="form-horizontal form-ajax" role="form" method="POST">{% csrf_token %}

            <div class="form-group">
                <label for="domain" class="control-label col-xs-12 col-sm-2">邮件域名</label>
                <div class="col-xs-12 col-sm-6">
                    <input type="text" class="form-control" id="domain" name="domain" placeholder="邮件域名" data-rule="required" />
                </div>
            </div>

            <div class="form-group layer-footer">
                    <label class="control-label col-xs-12 col-sm-2"></label>
                    <div class="col-xs-12 col-sm-6">
                        <a href="javascript:;" class="btn btn-success btn-embossed" >确定</a> 
                        <button type="reset" class="btn btn-default btn-embossed">重置</button>
                    </div>
                </div>
        </form>
    </div>
{% endblock %}

{% block footer %}
<script>
    $('#form').validator({
        valid: function (ret) {
            var data = $("#form").serialize();
            apiAjax("/mail/add/domain", data)
        }
    })
        // 使用链接代替submit按钮（注意：这种情况下输入框里面的回车键不能触发submit事件）
        .on("click", "a.btn.btn-success.btn-embossed", function (e) {
            $(e.delegateTarget).trigger("validate");
        });

</script>
{% endblock %}